package com.yzkj.framework.beans.exception;

import com.yzkj.framework.beans.result.ApiStatus;
import com.yzkj.framework.beans.result.BaseStatus;
import lombok.Getter;

/**
 * 自定义 API 异常父类
 */
@Getter
public class ApiException extends RuntimeException implements BaseStatus {

    private static final long serialVersionUID = 1L;

    /**
     * 异常状态码
     */
    private final Integer code;

    /**
     * 异常消息内容
     */
    private final String message;

    protected ApiException(int code, String message) {
        this.code = code;
        this.message = message;
    }

    protected ApiException(String message, Throwable cause) {
        super(message, cause);
        this.code = ApiStatus.INTERNAL_SERVER_ERROR.getCode();
        this.message = message;
    }
}
